@extends('layouts.app')
@section('title',$topic->excerpt)


@section('content')
    <div class="row">
        <div class="col-lg-3 col-md-3 d-none d-md-block">
            <div class="card">
                <div class="card-body">
                    <div class="text-center p-2 h5">
                        作者 : {{$topic->user->name}}
                    </div>
                    <div>
                        <a href="{{route('users.show',$topic->user_id)}}">
                            <img class="img-thumbnail" src="{{$topic->user->avatar}}" alt="{{$topic->user->name}}">
                        </a>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-9 col-sm-12">
            <div class="card">
                <div class="card-body">
                    <h4 class="text-center">{{$topic->title}}</h4>
                    <small class="d-flex justify-content-center text-secondary">
                        <span>{{$topic->created_at->diffForHumans()}}</span>
                        <span>&nbsp;•&nbsp;</span>
                        <span>
                            <i class="fa-regular fa-comment"></i>
                            {{$topic->reply_count}}
                        </span>
                    </small>
                    <div class="topic-body mt-4 mb-4">
                        {!! $topic->body !!}
                    </div>
                    @can('update',$topic)
                        <div class="text-center">
                            <hr/>
                            <a href="{{route('topics.edit',$topic->id)}}" class="btn btn-outline-success btn-sm">
                                <i class="fa fa-edit"></i>
                            </a>
                            &nbsp;&nbsp;
                            <form action="{{route('topics.destroy',$topic->id)}}" class="d-inline"
                                  method="POST" onsubmit="return confirm('您确定要删除吗?')"
                            >
                                @csrf
                                {{method_field('DELETE')}}

                                <button class="btn btn-outline-danger btn-sm" type="submit">
                                    <i class="fa fa-trash-alt"></i>
                                </button>
                            </form>
                        </div>
                    @endcan
                </div>
            </div>
            <div class="card mt-3">
                <div class="card-body">
                  @includeWhen(Auth::check(),'topics._reply_box',['topic'=>$topic])
                  @include('topics._reply_list',['replies'=>$topic->replies()->recent()->paginate(5)])
                </div>
            </div>
        </div>
    </div>
@stop



